package com.example.zzl.view.activity.HomeFragment;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.example.zzl.R;
import com.example.zzl.databinding.ActivityHotSpecialBinding;
import com.example.zzl.view.BaseView;
import com.example.zzl.viewmodel.HomeFragment.HotSpecialPresenter;

public class HotSpecialActivity extends AppCompatActivity implements HotSpecialPresenter.HotSpecialCallback {

    private ActivityHotSpecialBinding db;
    private HotSpecialPresenter presenter;
    private String headTitle;
    private int position;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getSupportActionBar().hide();
        super.onCreate(savedInstanceState);
        initIntent();
        db = DataBindingUtil.setContentView(this, R.layout.activity_hot_special);
        presenter = new HotSpecialPresenter(this, this, db);
        BaseView.initPresenter(presenter, Integer.toString(position + 1));
    }

    private void initIntent() {
        Bundle bundle = getIntent().getExtras();
        headTitle = bundle.getString("headTitle");
        position = bundle.getInt("position", 1);
    }


    @Override
    public String getHeadTitle() {
        return headTitle;
    }

    @Override
    public void startActivity(Class cls, Bundle bundle) {
        startActivityForResult(new Intent(this, cls).putExtras(bundle), 100);
    }


    @Override
    public void onClick(View v) {
//        Log.e("HotSpecialActivity", "onClick: " + v.getId());
        switch (v.getId()) {
            case -1:
                finish();
                break;

            case 0:

                break;

            default:
                break;
        }

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode == 100 && resultCode == 200) {
            finish();
        }
    }
}
